package com.contant;

import org.springframework.beans.BeansException;

import com.tunan.common.Result;
import com.tunan.lsj.check.IGenericCheck;
import com.tunan.lsj.check.exception.CheckException;
import com.tunan.system.persistence.model.SpringContextUtil;

/**
 * 校验列
 * @author samphin
 */
public class CheckBridge {
	public static synchronized Result validate(String[] validators,String[] m){
		try {
			for (int i = 0; i < validators.length; i++) {
				IGenericCheck sc=(IGenericCheck)SpringContextUtil.getBean(validators[i]);
				Result result=	sc.check(m[i]);
				if(!result.isSuccess())
					return result;
			}
		} catch (BeansException e) {
			e.printStackTrace();
		} catch (CheckException e) {
			e.printStackTrace();
		}
		return new Result();
	}
}
